package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component("teacher")
@Aspect
public class Teacher {
    @Pointcut("execution(* *(..))")
    public void pt(){}

    @Before("pt()")
    public void before() {
        System.out.println("每日回顾");
    }

    @AfterReturning("pt()")
    public void afterReturing() {
        System.out.println("每日总结");
    }

    @AfterThrowing("pt()")
    public void afterThrowing() {
        System.out.println("解答问题");
    }
    @After("pt()")
    public void after() {
        System.out.println("高薪就业");
    }

    public Object around(ProceedingJoinPoint pjp) {
        System.out.println("每日回顾");
        Object ret = null;
        try {
            //对原始方法的调用
            ret = pjp.proceed();

            System.out.println("每日总结");
        } catch (Throwable throwable) {
            System.out.println("解答问题");
        } finally {
            System.out.println("高薪就业");
        }
        return ret;
    }
}
